/**
 * Created by kevin on 17/3/22.
 */
import {
    RECEIVE_PRODUCTS,
    ADD_TO_CART
} from '../mutation-types'

const state = {
    all: []
}

const mutations = {
    [RECEIVE_PRODUCTS] (state, products) {
        state.all = products
    },
    [ADD_TO_CART] (state, products) {
        state.all.find(p => p.id === productId).inventory--
    }
}

export default {
    state,
    mutations
}